package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.MemberDao;
import com.itheima.pojo.Member;
import com.itheima.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;

/*
类简介：

功能：

时间：2020/4/6

*/
@Service(interfaceClass = MemberService.class)
public class MemberServiceImpl implements MemberService{

    @Autowired
    MemberDao memberDao;

    @Override
    public Integer addMember(Member member) {
        if (memberDao.isExit(member.getPhoneNumber()) > 0){
            //存在会员
            return memberDao.getId(member.getPhoneNumber());
        }

        if (memberDao.addMember(member) == 0){
            throw new RuntimeException("新增会员失败");
        }
        return member.getId();
    }
}
